<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateStatementTbl extends Migrator
{
    const TBL_NAME = 'statement';

    public function change()
    {
        // create the table
        $table  =  $this->table(addTablePrefix(self::TBL_NAME),[
            'engine'=>'InnoDB',
            'comment' => '统计表',
            'signed' => false
        ]);

        $table
            ->addColumn('session', 'string',array('limit'=>64,'default'=>'','comment'=>'session ID'))
            ->addColumn('browser', 'string',array('limit'=>32, 'default'=>'','comment'=>'客户端类型'))
            ->addColumn('ip',  'biginteger',array('default'=>0, 'comment'=>'客户端IP'))
            ->addColumn('visited', 'integer',array('signed'=>false,'default'=>0,'comment'=>'浏览次数'))
            ->addColumn('user_id', 'integer',array('signed'=>false,'default'=>0,'comment'=>'用户'))
            ->addColumn('create_time', 'integer',array('default'=>0,'comment'=>'创建时间'))
            ->addColumn('update_time', 'integer',array('default'=>0,'comment'=>'更新时间'))

            ->addIndex(array('session'))
            ->addIndex(array('create_time'))
            ->create();
    }
}
